home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
clean
/
sun3.lha
/
Sun3
/
_system.abc
< prev
next >
Wrap
Text File
|
1992-08-07
|
7KB
|
421 lines
| The system environment (for version numbers 0.80 etc)
|
.comp 800 111111111
.start _nostart_
.endinfo
.export EMPTY INT BOOL CHAR STRING REAL FILE _STRING_
.export _reserve _cycle_in_spine _hnf
.export _type_error _match_error _print_graph _eval_to_nf
.export _Tuple
.export _Select _select_code
.export _Nil _Cons
.export e_system_AP
.export e_system_IF e_system_lIF e_system_sIF e_system_nIF
.export _Defer _defer_code
.export _S.1 _S.2 _S.3 _S.4 _S.5 _S.6 n_S.1 n_S.2 n_S.3 n_S.4 n_S.5 n_S.6
|| don't change the order of the following 7 descriptors
.desc _STRING_ _hnf _hnf 0 ""
.desc STRING _hnf _hnf 0 "STRING"
.desc FILE _hnf _hnf 0 "FILE"
.desc REAL _hnf _hnf 0 "REAL"
.desc INT _hnf _hnf 0 "INT"
.desc BOOL _hnf _hnf 0 "BOOL"
.desc CHAR _hnf _hnf 0 "CHAR"
.desc EMPTY _hnf _hnf 0 "EMPTY"
.desc _Tuple _hnf _hnf 32 "_Tuple"
.desc _Select _hnf _hnf 2 "_Select"
.desc _Nil _hnf _hnf 0 "Nil"
.desc _Cons _hnf _l_cons 2 "Cons"
.desc e_system_AP _hnf e_system_lAP 2 "AP"
.desc e_system_IF e_system_nIF e_system_lIF 3 "IF"
.desc _Defer _hnf _apply_error 1 "_Defer"
.n 1 _Defer
.o 0 0
_defer_code:
print "Error: defer code entered\n"
halt
.o 0 2 i i
_match_error:
print "Run time error, rule \'"
printD
print "\' in module \'"
printD
print "\' does not match\n"
halt
.o 2 0
_l_cons:
create
push_a 2
push_args 2 2 2
fill _Cons 2 _hnf 2
update_a 0 2
pop_a 2
.d 1 0
rtn
.desc _S.1 n_S.1 _hnf 1 "_S.1"
.n 1 _S.1
.o 1 0
n_S.1:
push_node _reserve 1
jsr_eval
get_node_arity 0
pushI 1
push_arg_b 0
jsr_eval
getWL 2
fill_a 0 2
release
pop_a 2
.d 1 0
rtn
.desc _S.2 n_S.2 _hnf 1 "_S.2"
.n 1 _S.2
.o 1 0
n_S.2:
push_node _reserve 1
jsr_eval
get_node_arity 0
pushI 2
push_arg_b 0
jsr_eval
getWL 2
fill_a 0 2
release
pop_a 2
.d 1 0
rtn
.desc _S.3 n_S.3 _hnf 1 "_S.3"
.n 1 _S.3
.o 1 0
n_S.3:
push_node _reserve 1
jsr_eval
get_node_arity 0
pushI 3
push_arg_b 0
jsr_eval
getWL 2
fill_a 0 2
release
pop_a 2
.d 1 0
rtn
.desc _S.4 n_S.4 _hnf 1 "_S.4"
.n 1 _S.4
.o 1 0
n_S.4:
push_node _reserve 1
jsr_eval
get_node_arity 0
pushI 4
push_arg_b 0
jsr_eval
getWL 2
fill_a 0 2
release
pop_a 2
.d 1 0
rtn
.desc _S.5 n_S.5 _hnf 1 "_S.5"
.n 1 _S.5
.o 1 0
n_S.5:
push_node _reserve 1
jsr_eval
get_node_arity 0
pushI 5
push_arg_b 0
jsr_eval
getWL 2
fill_a 0 2
release
pop_a 2
.d 1 0
rtn
.desc _S.6 n_S.6 _hnf 1 "_S.6"
.n 1 _S.6
.o 1 0
n_S.6:
push_node _reserve 1
jsr_eval
get_node_arity 0
pushI 6
push_arg_b 0
jsr_eval
getWL 2
fill_a 0 2
release
pop_a 2
.d 1 0
rtn
.n 2 _Select
.o 1 0
_select_code:
print "Error: select code entered"
halt
.o 0 0
e_system_lAP:
print "Error: lazy entry of AP entered"
halt
.o 2 0
e_system_lIF:
repl_args 2 2
.d 3 0
jmp eval_args_if
.n 3 e_system_IF
.o 1 0
e_system_nIF:
push_node _reserve 3
.d 3 0
jsr eval_args_if
.o 1 0
getWL 1
fill_a 0 1
release
pop_a 1
.d 1 0
rtn
.o 3 0
eval_args_if:
jsr_eval
pushB_a 0
pop_a 1
.o 2 1 b
e_system_sIF:
jmp_false IFelse
update_a 0 1
pop_a 1
jmp_eval
IFelse:
pop_a 1
jmp_eval
.n 0 _Nil
.o 1 0
_hnf:
.d 1 0
rtn
.n 0 EMPTY
.o 1 0
_cycle_in_spine:
.o 1 0
_reserve:
print "Run Time Error: cycle in spine detected\n"
halt
.o 0 0
_type_error:
print "Run Time Error: type error\n"
halt
.o 0 0
_apply_error:
print "Run Time Error: apply error\n"
halt
.o 1 0
_print_graph:
.d 1 0
jsr _print
.o 0 0
print_sc "\n"
halt
.o 1 0
_print:
pushI 0 | push the bracket count
_continue_print:
jsr_eval
eq_desc _Cons 2 0
jmp_true _print_list
eq_desc _Nil 0 0
jmp_true _print_nil
eq_nulldesc _Tuple 0
jmp_true _print_tuple
get_node_arity 0
eqI_b 0 0 | check if arity is zero
jmp_true _print_last
print_sc "("
print_symbol_sc 0
push_b 0
push_b 0 | replace the node by
repl_args_b | leave arity on b-stack
_print_args:
print_sc " "
eqI_b 1 0 | check if last argument
jmp_true _print_last_arg
.d 1 0
jsr _print
.o 0 0
decI | decrease argument count
jmp _print_args
_print_last_arg:
pop_b 1 | remove argument count
incI | increment bracket count
jmp _continue_print | optimised tail recursion!
_print_last:
print_symbol_sc 0
pop_b 1 | remove arity
pop_a 1 | remove node
_print_brackets:
eqI_b 0 0 | stop printing brackets if
jmp_true _exit_brackets | bracket count is zero
print_sc ")"
decI | decrement bracket count
jmp _print_brackets
_exit_brackets:
pop_b 1 | remove bracket count
.d 0 0
rtn
_print_list:
print_sc "["
_print_rest_list:
repl_args 2 2
.d 1 0
jsr _print
.o 0 0
jsr_eval
eq_desc _Nil 0 0
jmp_true _print_last_list
print_sc ","
jmp _print_rest_list
_print_last_list:
print_sc "]"
pop_a 1
jmp _print_brackets
_print_nil:
print_sc "[]"
pop_a 1
jmp _print_brackets
_print_tuple:
print_sc "("
get_node_arity 0
push_b 0
push_b 0
repl_args_b
_print_rest_tuple:
.d 1 0
jsr _print
.o 0 0
decI
eqI_b 0 0
jmp_true _exit_print_tuple
print_sc ","
jmp _print_rest_tuple
_exit_print_tuple:
pop_b 1
print_sc ")"
jmp _print_brackets
.o 1 0
_eval_to_nf:
.d 1 0
jsr _eval
.o 0 0
halt
.o 1 0
_eval:
pushI 0 | push the bracket count
_continue_eval:
jsr_eval
eq_desc _Cons 2 0
jmp_true _eval_list
eq_desc _Nil 0 0
jmp_true _eval_nil
eq_nulldesc _Tuple 0
jmp_true _eval_tuple
get_node_arity 0
eqI_b 0 0 | check if arity is zero
jmp_true _eval_last
push_b 0
push_b 0 | replace the node by
repl_args_b | leave arity on b-stack
_eval_args:
eqI_b 1 0 | check if last argument
jmp_true _eval_last_arg
.d 1 0
jsr _eval
.o 0 0
decI | decrease argument count
jmp _eval_args
_eval_last_arg:
pop_b 1 | remove argument count
incI | increment bracket count
jmp _continue_eval | optimised tail recursion!
_eval_last:
pop_b 1 | remove arity
pop_a 1 | remove node
_eval_brackets:
eqI_b 0 0 | stop printing brackets if
jmp_true _exit_eval_brackets | bracket count is zero
decI | decrement bracket count
jmp _eval_brackets
_exit_eval_brackets:
pop_b 1 | remove bracket count
.d 0 0
rtn
_eval_list:
_eval_rest_list:
repl_args 2 2
.d 1 0
jsr _eval
.o 0 0
jsr_eval
eq_desc _Nil 0 0
jmp_true _eval_last_list
jmp _eval_rest_list
_eval_last_list:
pop_a 1
jmp _eval_brackets
_eval_nil:
pop_a 1
jmp _eval_brackets
_eval_tuple:
get_node_arity 0
push_b 0
push_b 0
repl_args_b
_eval_rest_tuple:
.d 1 0
jsr _eval
.o 0 0
decI
eqI_b 0 0
jmp_true _exit_eval_tuple
jmp _eval_rest_tuple
_exit_eval_tuple:
pop_b 1
jmp _eval_brackets